package name.as3.cmdFrameworks.core
{
import flash.utils.SafeGlobalOwner;
import flash.utils.SafeGlobalProxy;

import name.as3.cmdFrameworks.interfaces.ICommand;
import name.as3.cmdFrameworks.interfaces.IFacade;
import name.as3.cmdFrameworks.interfaces.IMediatorManagerDelegate;
import name.as3.cmdFrameworks.interfaces.INotification;

public class Command extends SafeGlobalOwner implements ICommand
{
	private var m_facade:IFacade;
	private var m_uiManager:IMediatorManagerDelegate;
	/**
	 *
	 */
	public function Command()
	{
		
	}
//==================================================================================================
// public
//==================================================================================================
	/**
	 * 
	 */
	public function execute(obNote:INotification):void
	{
		
	}
	/**
	 * 获取面板管理器代理
	 */
	public function get uiManager():IMediatorManagerDelegate
	{
		return m_facade.uiManager;
	}
	/**
	 * 发送消息
	 */
	public function sendNotification(strType:String, obData:* = null):void
	{
		var note:Notification = new Notification(strType, obData);
		note.setFacade(m_facade, super.sg);
		note.dispatch();
	}
	/**
	 * 执行命令
	 */
	public function invokeCommand(strType:String,
								  cCommand:Class,
								  obData:* = null,
								  blIsOneoff:Boolean = false):void
	{
		m_facade.addCommand(strType, cCommand);
		this.sendNotification(strType, obData);
	}
	/**
	 * 设置表面
	 */
	public function setFacade(value:IFacade, proxyGlobal:SafeGlobalProxy):void
	{
		m_facade = value;
		super.sg = proxyGlobal;
	}
	public function get facade():IFacade
	{
		return m_facade;
	}
}
}